package Engine.Model
{
	import Interface.Model.IEventManager;
	
	import library.Function.Dict;
	
	public class EventManager implements IEventManager
	{
		
		private var _eventDict:Dict;
		
		
		public function EventManager()
		{
			this._eventDict = new Dict(true);
		}
		
		public function registerEvent(eventID:int,fun:Function) : void
		{
			if(this._eventDict.has_key(eventID) || fun == null)
				return;
			this._eventDict.dictionary[eventID] = fun;
		}
		
		public function destroyEvent(eventID:int):void
		{
			this._eventDict.remove(eventID);
		}
		
		public function throwEvent(eventID:int,arg:Object = null):void
		{
			if(!this._eventDict.has_key(eventID))
				return;
			if(arg == null) 
				this._eventDict.dictionary[eventID]();
			else
				this._eventDict.dictionary[eventID](arg);
		}
	}
}